package ext.tianma.bom.service;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 根据物料编号模糊查询文档controller
 * 
 * @author lilin
 * @date 2018-11-21 00:37:01
 */
@Controller
@RequestMapping({ "/QueryDocumentController" })
public class QueryDocumentController {
	/**
	 * 根据接口参数查询数据并且返回固定格式的字符串
	 * 
	 * @param number
	 * @throws Exception
	 */
	@RequestMapping(value = "/queryDocument", method = { RequestMethod.POST,
			RequestMethod.GET })
	public void queryDocument(
			@RequestParam(value = "pdmName", required = true) String pdmName,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");// 返回文本值
		try {
			String result = QueryDocumentService.getAllDocument(pdmName);// 根据物料编号获取图文档
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
}
